#include "pit.h"
#include <QPainter>
#include <QPen>
#include <QStyleOptionGraphicsItem>
#include "ball.h"

Pit::Pit(int x, int y, int row, int col, int d) : m_row(row), m_col(col), d(d)
{
    setPos(x, y);
}

void Pit::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){
    painter->setPen(Qt::black);
    painter->drawEllipse(boundingRect());
}

QRectF Pit::boundingRect() const{
    return QRectF(0, 0, d, d);
}

Ball* Pit::getBall(){
    QList<QGraphicsItem*> ballList = collidingItems();
    if(ballList.size() == 1){
        Ball *ball = qgraphicsitem_cast<Ball*>(ballList[0]);
        return ball;
    }
    return 0;
}

